package com.xnck.demo.flowabledemo.helper.impl;


import com.xnck.demo.flowabledemo.helper.SubProcessHelper;
import org.flowable.engine.delegate.DelegateExecution;

import java.util.ArrayList;
import java.util.List;

public class SubProcessHelperImpl implements SubProcessHelper {

    @Override
    public List<String> getUserNames() {
        List<String> userNames = new ArrayList<>();
        userNames.add("test001");
        userNames.add("test002");
        userNames.add("test003");
        return userNames;
    }

    @Override
    public boolean isComplete(DelegateExecution execution) {
        Integer completeInstCount = (Integer) execution.getVariable("nrOfCompletedInstances");
        Integer instCount = (Integer) execution.getVariable("nrOfInstances");
        return completeInstCount > (float)instCount * 2 / 3;
    }
}
